import React from "react";
import { BrowserRouter, Route, Routes, Navigate } from "react-router-dom";
import Login from "../view/Login/Login";
import NewsSandBox from "../view/sandbox/NewsSandBox";
import News from "../view/news/News";
import Detail from "../view/news/Detail";
export default function IndexRouter() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/news" element={<News/>}></Route>
        <Route path="/detail/:id" element={<Detail/>}></Route>
        <Route path="/login" element={<Login></Login>}></Route>
        <Route
          path="/*"
          element={
            localStorage.getItem("token") ? (
              <NewsSandBox />
            ) : (
              <Navigate to="/login" />
            )
          }
        ></Route>
      </Routes>
    </BrowserRouter>
  );

}
